package com.jiandaoshou.utils;

/**
 * Created by Administrator on 2016/10/17.
 */
import com.lzy.okgo.callback.AbsCallback;

import org.json.JSONObject;

import okhttp3.Response;

public abstract class JsonCallback extends AbsCallback<String> {

    @Override
    public String convertSuccess(Response response) throws Exception {
        JSONObject jsonObject = new JSONObject(response.body().string());
        if(jsonObject.getInt("Success") == 1){
            return jsonObject.getString("Items");
        }else{
            throw new IllegalStateException(jsonObject.getString("ResultText"));
        }
    }
}